package com.deyuanyun.pic.ctrl.validatefun;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/**
 * 模块描述
 *
 * @author scalpel.王敏
 * @version [v1.0] 创建时间（2016/11/25）
 * @see // 引用的类
 * Method List:
 * 1.----------------
 * 2.----------------
 * History:
 */
public class MileageValid implements ValidateInterface {
    @Override
    public <T, E, C> boolean apply(T t, E e, C c) throws NoSuchFieldException {
        Field f=(Field) e;
        String val= (String) t;
        try {
            if(!StringUtils.isEmpty(val))
            {
                BeanUtils.setProperty(c,f.getName(),""+Double.valueOf(Double.valueOf(val)*1000).longValue());
            }
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (InvocationTargetException e1) {
            e1.printStackTrace();
        }
        return true;
    }

    @Override
    public String getName() {
        return null;
    }
}
